home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / dodge.swf / scripts / __Packages / EfficientTrailManager.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  2.2 KB  |  70 lines

  1. class EfficientTrailManager extends TrailManager
  2. {
  3.    var endTransform;
  4.    var trailClips;
  5.    var mc;
  6.    var trailNumber;
  7.    var number = 10;
  8.    var fade = true;
  9.    var rotType = 0;
  10.    function EfficientTrailManager(parent, target, trailNumber, color, number, fade, endTransform, rotType)
  11.    {
  12.       super(parent,target,trailNumber,color);
  13.       if(number != null)
  14.       {
  15.          this.number = number;
  16.       }
  17.       if(fade != null)
  18.       {
  19.          this.fade = fade;
  20.       }
  21.       if(rotType != null)
  22.       {
  23.          this.rotType = rotType;
  24.       }
  25.       this.endTransform = endTransform;
  26.       this.trailClips = new Array();
  27.       var _loc3_ = this.getCoords();
  28.       this.trailClips.push(this.mc.attachMovie("trail" + trailNumber,"t" + this.mc.getNextHighestDepth(),this.mc.getNextHighestDepth(),{x:_loc3_.x,y:_loc3_.y,cacheAsBitmap:true,_rotation:this.rotType}));
  29.    }
  30.    function makeTrail()
  31.    {
  32.       var _loc3_ = this.getCoords();
  33.       if(this.trailClips.length < this.number)
  34.       {
  35.          this.trailClips.push(this.createNewTrail());
  36.       }
  37.       var _loc2_ = this.trailClips.length - 1;
  38.       while(_loc2_ > 0)
  39.       {
  40.          this.trailClips[_loc2_]._x = this.trailClips[_loc2_ - 1]._x;
  41.          this.trailClips[_loc2_]._y = this.trailClips[_loc2_ - 1]._y;
  42.          _loc2_ = _loc2_ - 1;
  43.       }
  44.       this.trailClips[0]._x = _loc3_.x;
  45.       this.trailClips[0]._y = _loc3_.y;
  46.    }
  47.    function createNewTrail()
  48.    {
  49.       var _loc3_ = this.trailClips[this.trailClips.length - 1];
  50.       var _loc2_ = new Object();
  51.       if(this.fade)
  52.       {
  53.          _loc2_._alpha = 100 - (this.trailClips.length - 1) * (100 / this.number);
  54.       }
  55.       if(this.endTransform != null)
  56.       {
  57.          var _loc4_ = 100 - this.endTransform;
  58.          _loc2_._xscale = (this.endTransform - 100) / this.number * (this.trailClips.length - 1) + 100;
  59.          _loc2_._yscale = _loc2_._xscale;
  60.       }
  61.       _loc2_._rotation = this.rotType;
  62.       _loc2_.cacheAsBitmap = true;
  63.       return this.mc.attachMovie("trail" + this.trailNumber,"t" + this.mc.getNextHighestDepth(),this.mc.getNextHighestDepth(),_loc2_);
  64.    }
  65.    function die()
  66.    {
  67.       this.mc.removeMovieClip();
  68.    }
  69. }
  70.